<script type="text/javascript" src="./workify.js"></script>
<script type="text/javascript">
function add(a, b) {
  // importScripts('http://localhost:3000/workify/math.js');
  return math.add(a, b);
}
async function initFunc() {
  const workerAdd = workify(add, ['http://localhost:3000/workify/math.js']);
  console.log('workerAdd', await workerAdd(23, 16));
}
initFunc();

class Adder {
  constructor(initial) {
    this.count = initial;
    this.inner = {
      count: 15,
    };
  }
  add(a) {
    this.count += a;
    return this.count;
  }
}
async function initClass() {
  let WAdder = workify(Adder);
  let instance = await new WAdder(5);
  console.log('apply add', await instance.add(7));
  console.log('get count', await instance.count);
  console.log('get inner count', await instance.inner.count);
}
initClass();
</script>
